import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      component: () => import('../component/Login/index.vue')
    },
    {
      path: '/',
      redirect: "/homeview"
    },
    {
      path: "/homeview",
      name: 'homeview',
      component: () => import('../views/homeview.vue'),
      children: [
        { path: '/homeview', redirect: '/homeview/home' },

        { // 应用场景
          path: '/homeview/scene',
          name: 'scene',
          component: () => import('../views/Scene/index.vue')
        },
        // home页面
        {
          path: '/homeview/home',
          name: "home",
          component: () => import('../views/Home/index.vue')
        },
        //验证中心
        {
          path: '/homeview/proving',
          name: "proving",
          component: () => import('../views/Proving/index.vue')
        },
        // 帮助与文档
        {
          path: '/homeview/help',
          name: "help",
          component: () => import('../views/Help/index.vue')
        },
        // 数据监控大屏
        {
          path: '/homeview/monitor',
          name: "monitor",
          component: () => import('../views/Monitor/index.vue')
        },
        // 帮助与文档
        {
          path: '/homeview/doc',
          name: "doc",
          component: () => import('../views/Help/document_help.vue'),
          children: [
            { path: '/homeview/doc/', redirect: '/homeview/doc/overview' },
            {
              path: '/homeview/doc/overview',
              name: "overview",
              component: () => import('../views/Help/children/overview.vue')
            },
            {
              path: '/homeview/doc/advantage',
              name: "advantage",
              component: () => import('../views/Help/children/advantage.vue')
            },
            {
              path: '/homeview/doc/scene',
              name: "doc_scene",
              component: () => import('../views/Help/children/scene.vue')
            },
            {
              path: '/homeview/doc/term',
              name: "term",
              component: () => import('../views/Help/children/term.vue')
            },
            {
              path: '/homeview/doc/illustrate',
              name: "illustrate",
              component: () => import('../views/Help/children/illustrate.vue')
            },
            {
              path: '/homeview/doc/problem',
              name: "problem",
              component: () => import('../views/Help/problem/problem.vue')
            },
            {
              path: '/homeview/doc/purchase',
              name: "purchase",
              component: () => import('../views/Help/problem/purchase.vue')
            },
            {
              path: '/homeview/doc/login_reg',
              name: "login_reg",
              component: () => import('../views/Help/problem/login_reg.vue')
            },
          ]
        },
      ]
    },
    // 404页面
    {
      path: '/:catchAll(.*)',
      component: () => import('../views/404/index.vue')
    },
    // 控制台
    {
      path: "/console",
      name: "console",
      component: () => import('../component/consoleview/index.vue'),
      children: [
        { path: 'home', name: "homes", component: () => import('../component/Home/index.vue') },
        { path: "obtain", name: "obtain", component: () => import('../component/Forensics/index.vue') }, // 取证管理
        { path: "obtainadd", name: "obtainadd", component: () => import('../component/Forensics/Add.vue') }, // 取证添加
        { path: "obtaininfo", name: "obtaininfo", component: () => import('../component/Forensics/info.vue') }, // 取证详情
        { path: "existing", name: "existing", component: () => import('../component/existing/Existing.vue') }, // 存证管理
        { path: "addexisting", name: "addexisting", component: () => import('../component/existing/Addexisting.vue') }, //增加存证
        { path: "existinfo", name: "Evidenceinfo", component: () => import('../component/existing/Evidenceinfo.vue') },
        {
          path: "topup/order",
          name: "order",
          component: () => import('../component/topup/orderview.vue')
        },   //订单管理
        {
          path: "topup/shopp",
          name: "shop",
          component: () => import('../component/topup/shopview.vue')
        },   //购买服务
        { path: "account", name: "account", component: () => import('../component/Account/index.vue') }, // 账户管理
        { path: "payment", name: "payment", component: () => import('../component/topup/paymentview.vue') }, // 支付页面
        { path: "platform", name: "platform", component: () => import('../component/platform/index.vue') }, // 开放平台
        { path: "certified", name: "certified", component: () => import('../component/Account/certified.vue') }, // 个人实名认证
        { path: "enterprise", name: "enterprise", component: () => import('../component/Account/enterprise.vue') }, // 企业实名认证
      ]
    }
  ]
})
// router.beforeEach((to, from, next) => {
//   if (to.path === '/console') {
//     let token = window.sessionStorage.getItem('token')
//     if (!token) return next('/login')
//     next()
//   } else {
//     next()
//   }

// })
export default router
